package com.mc.servlet;

import com.mc.service.StudentService;
import com.mc.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zh
 * 删除学生
 */
@WebServlet("/studentdelete.action")
public class StudentDeleteServite extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //创建学生业务逻辑对象
        StudentService studentService=new StudentServiceImpl();
        String sidstr=req.getParameter("sid");
        System.out.println(sidstr);
        int sid=Integer.parseInt(sidstr);
        System.out.println(sid);
        boolean flag=studentService.delete(sid);
        System.out.println(flag);
        resp.sendRedirect("studentlist.action");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
